package cn.tukk.sparkproject.spark.session;

import scala.Serializable;
import scala.math.Ordered;

public class MyCategorySortKey implements Ordered<MyCategorySortKey>  , Serializable {

    private static final long serialVersionUID = 197033426188166691L;

    private int clickCount;
    private int orderCount;
    private int payCount;

    public MyCategorySortKey(int clickCount, int orderCount, int payCount) {
        this.clickCount = clickCount;
        this.orderCount = orderCount;
        this.payCount = payCount;
    }

    @Override
    public int compare(MyCategorySortKey that) {
        if(clickCount-that.getClickCount()!=0){
            return (int) (clickCount-that.getClickCount());
        }else if(orderCount-that.getOrderCount()!=0){
            return (int) (clickCount-that.getOrderCount());
        }else if(payCount-that.getPayCount()!=0){
            return (int) (payCount-that.getPayCount());
        }
        return 0;
    }

    @Override
    public boolean $greater(MyCategorySortKey other) {
        if(clickCount > other.getClickCount()) {
            return true;
        } else if(clickCount == other.getClickCount() &&
                orderCount > other.getOrderCount()) {
            return true;
        } else if(clickCount == other.getClickCount() &&
                orderCount == other.getOrderCount() &&
                payCount > other.getPayCount()) {
            return true;
        }
        return false;
    }

    @Override
    public boolean $greater$eq(MyCategorySortKey other) {
        if($greater(other)) {
            return true;
        } else if(clickCount == other.getClickCount() &&
                orderCount == other.getOrderCount() &&
                payCount == other.getPayCount()) {
            return true;
        }
        return false;
    }

    @Override
    public boolean $less(MyCategorySortKey other) {
        if(clickCount < other.getClickCount()) {
            return true;
        } else if(clickCount == other.getClickCount() &&
                orderCount < other.getOrderCount()) {
            return true;
        } else if(clickCount == other.getClickCount() &&
                orderCount == other.getOrderCount() &&
                payCount < other.getPayCount()) {
            return true;
        }
        return false;
    }

    @Override
    public boolean $less$eq(MyCategorySortKey other) {
        if($less(other)) {
            return true;
        } else if(clickCount == other.getClickCount() &&
                orderCount == other.getOrderCount() &&
                payCount == other.getPayCount()) {
            return true;
        }
        return false;
    }


    @Override
    public int compareTo(MyCategorySortKey that) {
        if(clickCount-that.getClickCount()!=0){
            return (int) (clickCount-that.getClickCount());
        }else if(orderCount-that.getOrderCount()!=0){
            return (int) (clickCount-that.getOrderCount());
        }else if(payCount-that.getPayCount()!=0){
            return (int) (payCount-that.getPayCount());
        }
        return 0;
    }



    public int getClickCount() {
        return clickCount;
    }

    public void setClickCount(int clickCount) {
        this.clickCount = clickCount;
    }

    public int getOrderCount() {
        return orderCount;
    }

    public void setOrderCount(int orderCount) {
        this.orderCount = orderCount;
    }

    public int getPayCount() {
        return payCount;
    }

    public void setPayCount(int payCount) {
        this.payCount = payCount;
    }

    @Override
    public String toString() {
        return "MyCategorySortKey{" +
                "clickCount=" + clickCount +
                ", orderCount=" + orderCount +
                ", payCount=" + payCount +
                '}';
    }
}
